package com.ruoyi.web.dorm.service.impl;

import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.web.dorm.entity.HealthEntity;
import com.ruoyi.web.dorm.mapper.DormHealthMapper;
import com.ruoyi.web.dorm.service.DormHealthService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DormHealthServiceImpl implements DormHealthService {
    @Autowired
    private DormHealthMapper dormHealthMapper;


// 查询宿舍卫生
    @Override
    public List<HealthEntity> getDormHealth(HealthEntity healthEntity) {
        return dormHealthMapper.getDormHealth(healthEntity);
    }
//添加宿舍卫生信息
    @Override
    public int addDormHealth(HealthEntity healthEntity) {
        String username = SecurityUtils.getLoginUser().getUsername(); //获取创建人的名字 添加进去
        healthEntity.setCreateBy(username);
        return dormHealthMapper.addDormHealth(healthEntity);
    }
//修改宿舍卫生信息
    @Override
    public int updateDormHealth(HealthEntity healthEntity) {
        String username = SecurityUtils.getLoginUser().getUsername(); //获取创建人的名字 添加进去
        healthEntity.setUpdateBy(username);
        return dormHealthMapper.updateDormHealth(healthEntity);
    }
//删除宿舍卫生信息
    @Override
    public int delDormHealth(Long id) {
        return dormHealthMapper.delDormHealth(id);
    }
}
